package com.jenings.shop.service;

import com.jenings.shop.entity.Notice;
import com.jenings.shop.mapper.NoticeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true)
/** @Transactional 可以保证数据的一致性，放在service层是因为一个service类可能有多个方法，如果放在dao，只保证到一个dao的数据一致*/
public class NoticeService {
    @Autowired
    NoticeMapper noticeMapper;
    //查询全部公告

    public List<Notice> selectAll(){
        List<Notice> noticeList = noticeMapper.selectAll();
        return noticeList;
    }
    //查询部分公告
    public List<Notice> selectSome(String ggname){
        List<Notice> noticeList = noticeMapper.selectSome(ggname);
        return noticeList;
    }
    //查询单独公告
    public Notice selectByte(Integer ggid){
        Notice notice = noticeMapper.selectByte(ggid);
        return notice;
    }
    //删除公告
    @Transactional(readOnly = false)
    public boolean delByte(Integer ggid){
        return noticeMapper.delByte(ggid);
    }
    //增加公告
    @Transactional(readOnly = false)
    public boolean addByte(Notice notice){
        return noticeMapper.addByte(notice);
    }
}
